package com.atguigu.day22.work;

import com.sun.glass.ui.Size;
import org.junit.Test;

import java.io.File;

public class Work9 {
    @Test
    public void w1(){
        File f1=new File("d:/program");
        long size= size(f1);
        System.out.println("大小:"+size);
    }
    public long size(File file){
        if (file.isFile()){
            return file.length();
        }else if (file.isDirectory()){
            File[] list=file.listFiles();
            long sum=0;
            for (File file1 : list) {
                sum+=size(file1);
            }
            return sum;
        }
        return 0;
    }
}
